##use strict;
use HTML::TreeBuilder;
use File::Path;
use Time::Local 'timelocal';
use warnings;
use File::Spec::Functions;
use Cwd;
my $MP_Filename ="China_Product_SW_Update_Schedule_MP.xlsx";
my $SD_Filename ="China_Product_SW_Update_Schedule_SD.xlsx";
my $currentdir= "C:\\FileChangeNotifyTool";
my $oldfilepath= "C:\\FileChangeNotifyTool\\Old_Files";
my $MP_Time_Stamp_path = $oldfilepath.'\\MP_Time_Stamp.txt';
my $SD_Time_Stamp_path = $oldfilepath.'\\SD_Time_Stamp.txt';
my $Old_MP_File_Path = $oldfilepath.'\\'.$MP_Filename;
my $Old_SD_File_Path = $oldfilepath.'\\'.$SD_Filename;


#print $MP_Time_Stamp_path;
#print "\n";
#print $SD_Time_Stamp_path;
#print "\n";



my @MP =stat($Old_MP_File_Path);
if ($MP[9] eq ''){
	print "File Not found\n";
}
my $MPModifyTime =$MP[9];
print $MPModifyTime;
print "\n";
print "Initiate success\n";

open(MP_TS_FILE_pre, "C:\\FileChangeNotifyTool\\Old_Files\\MP_Time_Stamp.txt") or die "Can't open $MP_Time_Stamp.\n";
my $MP_Times ='';
while(<MP_TS_FILE_pre>)
{
        chomp;
        print "$_\n";
		$MP_Times = $_;
}
close(MP_TS_FILE_pre);

if ($MPModifyTime ne $MP_Times)
{
open(MP_TS_FILE, ">>C:\\FileChangeNotifyTool\\Old_Files\\MP_Time_Stamp.txt") or die "Can't open $MP_Time_Stamp.\n";
print "File is not equal to old one! Update the new time to log files";
print MP_TS_FILE $MPModifyTime;
print MP_TS_FILE "\n";
close(MP_TS_FILE);
} else {
print "File Modify time is the same, do not update and contiue\n"
}

